<?php

namespace app\order\logic;

use app\common\library\RedissLock;
use app\common\service\JinyiApiService;
use app\common\service\ShunfengApiService;
use think\facade\Db;

class OrderWhServiceLogic
{
    /**
     * 网红小店订单发货队列消费
     * @param $data
     * @return void
     */
    public function orderWhShippingQueueConsume($data)
    {

        htmlLog(['data'=>$data],OPERATE_LOG . date('Ym') . '/orderWhShippingQueueConsume/' . date('Ymd') . '.txt');
        if(!$data['warehouse_id']) return  true;
        $log = [
            'code'         => 1,
            'order_id'     => $data['order_id'],
            'shop_id'      => $data['shop_id']??'',
            'time'         => time(),
            'warehouse_id' => $data['warehouse_id']
        ];
        OrderWhLogic::insertOrderWhLog($log);

        if ($data['warehouse_id'] == 3) {
            $jinyiApi = new JinyiApiService();
            $jinyiApi->createOrderWh($data);
        }

        if ($data['warehouse_id'] == 4) {
            $shunfengApi = new ShunfengApiService();
            $shunfengApi->createOutBoundOrderWh($data);
        }
        return  true;
    }
}
